//
//  UIBarBauttonItem+Extensions.swift
//  Weibo2
//
//  Created by 伏文东 on 2018/2/6.
//  Copyright © 2018年 伏文东. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    convenience init(title: String, fontSize: CGFloat = 16, target: Any, action: Selector, isBack: Bool = false) {
        let button = UIButton.textButton(title: title, fontSize: fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        
        if isBack {
            let imageName = "navigationbar_back_withtext"
            button.setImage(UIImage(named: imageName), for: .normal)
            button.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
            button.sizeToFit()
        }
        
        button.addTarget(target, action: action, for: .touchUpInside)
        
        self.init(customView: button)
    }
}
